//
//  BaseBottomView.m
//  HubeiHotel
//
//  Created by LiBenCan on 17/11/23.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "BaseBottomView.h"
#import "BaseMBView.h"
@interface BaseBottomView()
@property (nonatomic,strong)NSString  *typeStr;//类型
@property (nonatomic, strong)NSArray *firstArr;//主数据
@property (nonatomic,strong)NSMutableArray *chooseArr;
@property (nonatomic, strong)NSArray *secondArr;//备用 万一用到了呢
@end

@implementation BaseBottomView

- (instancetype)initWithFrame:(CGRect)frame KindStr:(NSString *)kindStr DataArr:(NSArray *)dataArr SecondArr:(NSArray *)dataArr2 ChooseArr:(NSMutableArray *)chooseArr
{
    if (self = [super initWithFrame:frame]) {
        //变成全局数据
        dataArr = @[@"推荐商圈",@"洪山区",@"汉阳区",@"武昌区",@"武昌区2",@"武昌区3",@"武昌区4",@"武昌区5",@"武昌区5",@"武昌区6"];
        dataArr2 = @[@"没事",@"美味",@"哈哈哈",@"不是"];
        _typeStr = kindStr;
        _firstArr = dataArr;
        _secondArr = dataArr2;
        _chooseArr = [[NSMutableArray alloc]initWithArray:chooseArr];
        [self creatView:frame];
    }
    return self;
}


-(void)creatView:(CGRect)frame//构建蒙板
{
    if (!_baseBgView) {
        _baseBgView = [[BaseMBView alloc]initWithFrame:frame];
        [_baseBgView showView:[TomamaUI getTopVC]];
        __weak typeof(self)weakSelf = self;
        _baseBgView.dissBlock = ^(){//点击空白
            if (weakSelf.chooseTapBlock) {
                weakSelf.chooseTapBlock(weakSelf.chooseArr,@"确定");
            }
        };
    }
    if ([_typeStr isEqualToString:@"区域"]  || [_typeStr isEqualToString:@"附近"]) {
        [_baseBgView addSubview:self.leftTableV];
        [_baseBgView addSubview:self.rightTableV];
        [self Right:CGRectMake(100*screenW_6, 0,SCREENW-100*screenW_6,360*screenW_6)];
        
    }else if ([_typeStr isEqualToString:@"智能排序"]) {
        [self initZhiNengData];
        [_baseBgView addSubview:self.rightTableV];
        [self Right:CGRectMake(0, 0,SCREENW,160*screenW_6)];
        
    }else if ([_typeStr isEqualToString:@"职位筛选"] || [_typeStr isEqualToString:@"公司筛选"] || [_typeStr isEqualToString:@"全部"] ) {
        [self initDataArr];
        [_baseBgView addSubview:self.ChooseLabTableV];
        [self ChooseLabTab:CGRectMake(0, 0,SCREENW,SCREENH-64-40*screenW_6)];
    }
}

-(LeftTableView *)leftTableV
{
    if (!_leftTableV) {
        _leftTableV  = [[LeftTableView alloc]initWithFrame:CGRectMake(0, 0, 100*screenW_6, 360*screenW_6)];
    }
    [_leftTableV WithFrame:CGRectMake(0, 0, 100*screenW_6, 360*screenW_6) KindStr:_typeStr DataArr:_firstArr SecondArr:_secondArr ChooseArr:_chooseArr];
    __weak typeof(self)weakSelf = self;
    _leftTableV.chooseRowBlock = ^(NSInteger chooseRow,NSMutableArray *chooseNowArr){//选择Row的回调
        _chooseArr = chooseNowArr;
        //刷新右边的数据
        [weakSelf.rightTableV WithFrame:weakSelf.rightTableV.frame KindStr:weakSelf.typeStr DataArr:weakSelf.firstArr SecondArr:weakSelf.secondArr ChooseArr:weakSelf.chooseArr];
        if (weakSelf.chooseTapBlock) {
            weakSelf.chooseTapBlock(chooseNowArr,@"改变数组");
        }
    };
    return _leftTableV;
}

-(RightTableView*)rightTableV
{
    if (!_rightTableV) {
        _rightTableV  = [[RightTableView alloc]initWithFrame:CGRectMake(100*screenW_6, 0,SCREENW-100*screenW_6,360*screenW_6)];
    }
    return _rightTableV;
}
-(void)Right:(CGRect)frame
{
    [_rightTableV WithFrame:frame KindStr:_typeStr DataArr:_firstArr SecondArr:_secondArr ChooseArr:_chooseArr];
    __weak typeof(self)weakSelf = self;
    _rightTableV.chooseRowBlock = ^(NSInteger chooseRow,NSMutableArray *chooseNowArr){//选择Row的回调
        _chooseArr = chooseNowArr;
        if (weakSelf.chooseTapBlock) {
            weakSelf.chooseTapBlock(chooseNowArr,@"改变数组");
            weakSelf.chooseTapBlock(chooseNowArr,@"确定");
        }
        
    };
}
-(ChooselabView*)ChooseLabTableV
{
    if (!_ChooseLabTableV) {
        _ChooseLabTableV  = [[ChooselabView alloc]initWithFrame:CGRectMake(0, 0,SCREENW,SCREENH-64-40*screenW_6)];
    }
    return _ChooseLabTableV;
}

-(void)ChooseLabTab:(CGRect)frame
{
    [_ChooseLabTableV WithFrame:frame KindStr:_typeStr DataArr:_firstArr SecondArr:_secondArr ChooseArr:_chooseArr];
    __weak typeof(self)weakSelf = self;
    _ChooseLabTableV.chooseRowBlock = ^(NSMutableArray *chooseNowArr,NSString *title){
        _chooseArr = chooseNowArr;
        //选择Row的回调
        if (weakSelf.chooseTapBlock) {
            weakSelf.chooseTapBlock(chooseNowArr,title);
        }
    };
}

-(void)initDataArr//工作经历
{
    _firstArr = @[@[@"月薪范围（不限）",@[@"2k以下",@"2k－5k",@"5k－10k",@"50k以上"]],
                  @[@"工作经历",@[@"应届毕业生",@"3年及以下",@"3～5年",@"5～10年",@"10年以上",@"经验不限"]],
                  @[@"学历要求",@[@"大专",@"本科",@"博士",@"硕士",@"不要求"]],
                  @[@"工作性质",@[@"全职",@"兼职",@"实习"]],
                 ];
}
-(void)initZhiNengData
{
    _secondArr = @[@"智能排序",@"离我最近",@"好评优先",@"人气最高"];
}
@end
